﻿//******************************************************************************************************
//  ReceiverEntry.cs - Gbtc
//
//  Copyright © 2010, Grid Protection Alliance.  All Rights Reserved.
//
//  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
//  the NOTICE file distributed with this work for additional information regarding copyright ownership.
//  The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
//  not use this file except in compliance with the License. You may obtain a copy of the License at:
//
//      http://www.opensource.org/licenses/eclipse-1.0.php
//
//  Unless agreed to in writing, the subject software distributed under the License is distributed on an
//  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
//  License for the specific language governing permissions and limitations.
//
//  Code Modification History:
//  ----------------------------------------------------------------------------------------------------
//  07/09/2010 - Stephen C. Wills
//       Generated original version of source code.
//
//******************************************************************************************************

using System;
using TVA.Communication;

namespace TestBenchApi.Package
{
    /// <summary>
    /// Contains settings for a receiver.
    /// </summary>
    public class ReceiverEntry : Entry
    {

        #region [ Properties ]

        /// <summary>
        /// Gets or sets the internet protocol used to receive data from the concentrator.
        /// </summary>
        public TransportProtocol InputProtocol
        {
            get
            {
                return (TransportProtocol)Enum.Parse(typeof(TransportProtocol), Settings["inputProtocol"], true);
            }
            set
            {
                Settings["inputProtocol"] = value.ToString();
            }
        }

        /// <summary>
        /// Gets or sets the port that the receiver listens on.
        /// </summary>
        public int Port
        {
            get
            {
                return int.Parse(Settings["port"]);
            }
            set
            {
                if (value < 0 || value > 65535)
                    throw new ArgumentException("value");

                Settings["port"] = value.ToString();
            }
        }

        /// <summary>
        /// Gets or sets the name of the file to which data is written.
        /// </summary>
        public string OutputFile
        {
            get
            {
                return Settings["dataFile"];
            }
            set
            {
                Settings["dataFile"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the name of the file to which timestamp data is written.
        /// </summary>
        public string TimestampFile
        {
            get
            {
                return Settings["timestampFile"];
            }
            set
            {
                Settings["timestampFile"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the port through which the receiver sends commands to the concentrator.
        /// </summary>
        public int CommandChannelPort
        {
            get
            {
                return int.Parse(Settings["commandChannelPort"]);
            }
            set
            {
                if (value < 0 || value > 65535)
                    throw new ArgumentException("value");

                Settings["commandChannelPort"] = value.ToString();
            }
        }

        #endregion
        
    }
}
